#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QSerialPort>
#include <QSerialPortInfo>
#include "data_proc.h"

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

private slots:
    void on_open_close_clicked();

    void on_pb_exit_clicked();

    void on_pb_self_check_clicked();

    void on_rb_absolute_time_clicked();

    void on_rb_relative_time_clicked();

    void on_pb_input_parameter_clicked();

    void on_pb_calibrate_time_clicked();

    void dte_current_update();

    void on_cb_handshakestate_stateChanged(int arg1);

private:
    Ui::Widget *ui;
    QSerialPort *mserial;
    bool is_opened;
    void serial_set();
    bool serial_open();
    std::string read_data();
    void write_data(const QByteArray &data);
    void serial_close();
    DATA_PROC dp;
    void recv_handshake(QByteArray &msg);
    void recv_selfcheck(QByteArray &msg);
    void recv_inputparameter(QByteArray &msg);
    void recv_timealign(QByteArray &msg);
    QTimer *timer;

};
#endif // WIDGET_H
